package com.midou.administration.config;

import com.midou.administration.Interceptor.AuthorityInterceptor;
import com.midou.administration.entity.Function;
import com.midou.administration.service.FunctionService;
import com.midou.administration.service.RoleFunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private RoleFunctionService roleFunctionService;
    @Autowired
    private FunctionService functionService;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthorityInterceptor(roleFunctionService,functionService))
                .addPathPatterns("/**") // 配置拦截路径（所有路径都拦截）
                .excludePathPatterns("/login") // 配置排除的路径
                .excludePathPatterns("/register");

    }
}
